//
//  ReportProjectDetailModel.m
//  efairy
//
//  Created by 李锋 on 2019/3/18.
//  Copyright © 2019年 East. All rights reserved.
//

#import "ReportProjectDetailModel.h"
#import "EFADeviceModel.h"

@implementation AlarmTimesInfoList
- (NSString *)ptDes {
    NSDictionary *dic = [[EFADeviceProtocolModel sharedInstance] protocolInfoWithPt:self.pt];
    if (dic) {
        return dic[EFADeviceProtocolPtTitle];
    }
    return @"未定义";
}
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
@end

@implementation AlarmPercentInfoList
- (NSString *)ptDes {
    NSDictionary *dic = [[EFADeviceProtocolModel sharedInstance] protocolInfoWithPt:self.pt];
    if (dic) {
        return dic[EFADeviceProtocolPtTitle];
    }
    return @"未定义";
}
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }

@end

@implementation StatisticsList
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
@end

@implementation AlarmStatisticsList
- (NSArray<NSDictionary *> *)pieData {
    NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:self.alarm_percent_info_list.count];
    // 颜色值
    NSArray *color = @[@"#4D68FA",@"#3CE4FF",@"#7CD89E", @"#FFA954", @"#629CE6", @"#E671D7", @"#B28CE5"];
    [self.alarm_percent_info_list enumerateObjectsUsingBlock:^(AlarmPercentInfoList * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSInteger index = idx % color.count;
        NSDictionary *temp = @{@"name" : obj.ptDes,
                               @"color" : color[index],
                               @"y" : @(obj.percent)
                               };
        
        [mArray addObject:temp];
    }];
    return mArray;
}

- (NSArray<NSDictionary *> *)columnData {
    NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:self.alarm_times_info_list_t.count];
//    NSMutableArray arrayWithObjects
    // 颜色值
    NSArray *color = @[@"#4D68FA",@"#3CE4FF",@"#7CD89E", @"#FFA954", @"#629CE6", @"#E671D7", @"#B28CE5"];
    [self.alarm_times_info_list_t enumerateObjectsUsingBlock:^(AlarmTimesInfoList * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSInteger index = idx % color.count;
        NSDictionary *temp = @{@"name" : obj.ptDes,
                               @"color" : color[index],
                               @"y" : @(obj.times)
                               };
        [mArray addObject:temp];
    }];
    return mArray;
}



//必需实现“encodeWithCoder”和“initWithCoder”函数才能解析，如果有嵌套对象还需要实现“modelContainerPropertyGenericClass”函数
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass {
    return @{@"alarm_percent_info_list"  : [AlarmPercentInfoList class],
             @"alarm_times_info_list_t":[AlarmTimesInfoList class]
             };
}
@end

@implementation ProjectReportSummary
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
@end

@implementation DeviceAlarmStatistics
//必需实现“encodeWithCoder”和“initWithCoder”函数才能解析，如果有嵌套对象还需要实现“modelContainerPropertyGenericClass”函数
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass {
    return @{@"device_alarm_statistics_list"  : [AlarmStatisticsList class]};
}
@end

@implementation DeviceStatistics
//必需实现“encodeWithCoder”和“initWithCoder”函数才能解析，如果有嵌套对象还需要实现“modelContainerPropertyGenericClass”函数
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass {
    return @{@"device_statistics_list"  : [StatisticsList class]};
}
@end

@implementation ReportProjectDetailModel
//必需实现“encodeWithCoder”和“initWithCoder”函数才能解析，如果有嵌套对象还需要实现“modelContainerPropertyGenericClass”函数
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; }
- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass {
    return @{@"efairyproject_device_statistics"  : [DeviceStatistics class],
             @"efairyproject_device_alarm_statistics"  : [DeviceAlarmStatistics class],
             @"efairyproject_report_summary"  : [ProjectReportSummary class]
             };
}
@end
